﻿using Inaction;
using Inaction.Core;
using System;
using System.ComponentModel;

namespace Inaction.DbSchame
{
    [Serializable]
    public abstract class NameObject : INameObject
    {
        string name = string.Empty;
        [DisplayName("名称")]
        public string Name
        {
            get { return name; }
            set { name = value; }
        }
        [DisplayName("描述")]
        public string DisplayName { get; set; }

        string formatName = string.Empty;
        public string FormatName
        {
            get
            {
                if (string.IsNullOrEmpty(formatName))
                    formatName = DbProvider.Instance.FormatName(name);
                return formatName;
            }
        }

        public override string ToString()
        {
            return (string.IsNullOrEmpty(Name) ? "" : Name) + (string.IsNullOrEmpty(DisplayName) ? "" : ":" + DisplayName);
        }
    }

    public enum ConstraintType
    {
        [Description("C")]
        Normal,
        [Description("P")]
        Primary,
        [Description("F")]
        ForeignKey,
        [Description("U")]
        Unquie,
    }
}
